package edu.gatech.asthma.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import edu.gatech.asthma.R;
import edu.gatech.asthma.database.DBAdapter;
import edu.gatech.asthma.database.ProfileVO;
import edu.gatech.asthma.ui_support.HelpMenuHelper;
import edu.gatech.asthma.ui_support.ProfileCustomizer;

/**
 * Allows parent to update patient information about the child
 */
public class ShowProfileActivity extends Activity{

	int identifier = -1;
	DBAdapter database;
	ProfileCustomizer customizer;
	String heightInfo = "";
	String weightInfo = "";
	String ethnicityInfo = "";

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show_profile);

		getActionBar().setTitle("Patient Information");

		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			identifier = extras.getInt("ID");
		}

		database = new DBAdapter(this);
		database.open();

		ProfileVO patientProfile = database.getProfile(identifier);

		TextView nameData = (TextView) findViewById(R.id.txtNameData);
		TextView genderData = (TextView) findViewById(R.id.txtGenderData);
		TextView birthdayData = (TextView) findViewById(R.id.txtBirthdayData);
		TextView heightData = (TextView) findViewById(R.id.txtHeightData);
		TextView weightData = (TextView) findViewById(R.id.txtWeightData);
		TextView ethnicityData = (TextView) findViewById(R.id.txtEthnicityData);

		nameData.setText(patientProfile.getName());

		if(patientProfile.getGender() == 0) {
			genderData.setText("Male");
		} else {
			genderData.setText("Female");
		}

		birthdayData.setText(patientProfile.getBirthday());

		if(patientProfile.getHeight_unit() == 0) {
			int feet = patientProfile.getHeight() / 12;
			int inch = patientProfile.getHeight() % 12;
			heightInfo = feet + " Feet " + inch + " Inches";
		} else {
			heightInfo = patientProfile.getHeight() + " Centimeters";
		}
		heightData.setText(heightInfo);

		if(patientProfile.getWeight_unit() == 0){
			weightInfo = patientProfile.getWeight() + " Pounds";
		} else {
			weightInfo = patientProfile.getWeight() + " kg";
		}
		weightData.setText(weightInfo);

		switch (patientProfile.getEthnicity()) {
		case 0:
			ethnicityInfo = "Caucasian";
			break;
		case 1:
			ethnicityInfo = "Black/African";
			break;
		case 2:
			ethnicityInfo = "Latin/Hispanic";
			break;
		case 3:
			ethnicityInfo = "Asian/Pacific Islander";
			break;
		case 4:
			ethnicityInfo = "Indian";
			break;
		case 5:
			ethnicityInfo = "Mixed/Other";
		default:
			ethnicityInfo = "Mixed/Other";
			break;
		}
		ethnicityData.setText(ethnicityInfo);
	}
	
	/**
	 * User clicked the help button on this screen
	 * @param v ImageView clicked
	 */
	public void helpButtonClicked(View v) {
		HelpMenuHelper.displayHelpMessage(this);
	}

}
